<%
'******************************************************************************************
'#          Openasp CMS software opensource                                               #
'******************************************************************************************
'#      Copyright (C) Luca Becchetti, Broken Ice Interactive                              #
'#                                                                                        #
'# Questo software è gratuito, è possibile ridistribuire e modificare il prodotto         #
'# rispettando i termini della GNU General Public License pubblicata dalla Free           #
'# Software Foundation, si fa riferimento alla versione attuale e a tutte le versioni.    #
'# future                                                                                 #
'#                                                                                        #
'# Il software viene distribuito con lo scopo di essere utile e di aiutare nella          #
'# realizzazione di un sito web, non ci assiumiamo nessuna responsabilità per             #
'# eventuali malfunzionamenti o problemi provenienti dal programma.                       #
'#                                                                                        #
'# E' assolutamente vietato eliminare ogni riferimento di copyright sia all'interno del   #
'# del codice sorgente sia quelli visivi nel progetto.                                    #
'#                                                                                        #
'# Una copia della licenza GNU GPL è rilasciata nel pacchetto di istallazione del         #
'# software.                                                                              #
'#                                                                                        #
'# Per supporto visita il nostro sito ufficiale                                           #
'# http://www.openasp.it                                                                  #
'#                                                                                        #
'#                                                                                        #
'******************************************************************************************
'
'--------------------------------------------------------------------------------------------

i = split(request.ServerVariables("HTTP_URL"), "/")
if strComp("hello.asp", i(Ubound(i)), 1) = 0 then
  response.redirect request.servervariables("HTTP_REFERER")
end if

'L'id del blog da gestire
idblog = 1

	
function removeHtmlChar(ss)
	t = ""
	l=len(ss)
	for i=1 to l
		ch=mid(ss,i,1)
		x=i
		if(ch="<") then
			x=i
			do while(mid(ss,x,1)<>">")
				x=x+1		
			loop
			t=t & " "
		else
			t=t & ch	
		end if
		i=x	
	next
	ss=t
end function

Function TextPreview(strText, nChars)
	Dim nPos

    	' Uncomment next line to replace line breaks with spaces
	' strText = Replace(strText, vbCrLf, " ")

	' Check if it's longer than limit
    	If Len(strText) > nChars And nChars > 4 Then
        	' Find the end of last whole word that we can use
        	nPos = InStrRev(Left(strText, nChars - 3), " ")

        	If nPos > 0 Then
			' Take whole words only 
            		TextPreview = Left(strText, nPos) & "..."
        	Else
			' No spaces were found - take what we can
            		TextPreview = Left(strText, nChars - 4) & " ..."
	        End If
    	Else
		' Take nChars from the text
        	TextPreview = Left(strText, nChars)
    	End If
End Function

Function isBlogMod(id, categ)
	if id <> "" and categ <> "" then
		if isNumeric(user) and isNumeric(cat) then
			set testRS = addConn.Execute("SELECT * FROM tb_blog_moderazione WHERE utente = " & id & " AND idcategoria = " & categ)
			if not testRS.EOF then
				isBlogMod = true
			else
				isBlogMod = false
			end if
		else
			isBlogMod = false
		end if
	else
		isBlogMod = false
	end if
End Function

'Recupero i dati per la configurazione del blog
set dtRS = addConn.Execute("SELECT * FROM tb_blog_blogs WHERE id_blog = " & idblog)
MAX_POST_PAGE = dtRS("maxpostpage")
RIASTEXT = dtRS("riastext")
MAX_COM_PAGE = dtRS("maxcommpage")
REG_COM = dtRS("regcom")
set dtRS = Nothing

function nomeCat(id)
	set cs = addConn.Execute("SELECT nome_categoria FROM tb_blog_categorie WHERE id_categoria = " & id)
		if not cs.EOF then
			nomeCat = cs("nome_categoria")
		else
			nomeCat = "unknown"
		end if
	set cs = Nothing
end function

function totCommenti(id)
	set cs = addConn.Execute("SELECT count(*) as totale FROM tb_blog_commenti WHERE pubblico = 1 AND post = " & id)
		totCommenti = cs("totale")
	set cs = Nothing
end function

Select case request.QueryString("pass")

case "", 0:
iPageSize = MAX_POST_PAGE
			'se non si stà richiedendo nessuna pagina assegno per default il valore 1
				If Request.QueryString("page") = "" Then
					iPageCurrent = 1
				Else
					'Altrimenti assegno la pagina recuperata
					iPageCurrent = CInt(Request.QueryString("page"))
				End If	
					
if DB_TYPE = "mysql" then
					
				start = (iPageCurrent -1)*iPageSize
				send = iPageSize

				SQL = "SELECT count(*) AS TOTALE FROM tb_blog_posts WHERE blog = " & idblog & " AND pubblico = 1 ORDER BY id_post DESC"
			
				Set a = objConn.Execute(SQL)	
				tot = Cint(a("TOTALE"))
				'Recupero il totale delle pagine
				if tot < iPageSize then
					iPageCount = 1
				elseif tot mod iPageSize = 0 then
					iPageCount = Int(tot/iPageSize)
				else
					iPageCount = Int((tot/iPageSize)) + 1
				End if				
	
				Set pRS = Server.CreateObject("ADODB.RecordSet")
				strSQL = "SELECT * FROM tb_blog_posts WHERE blog = " & idblog & " AND pubblico = 1 ORDER BY id_post DESC Limit "&start&","&send&""
				pRS.Open strSQL, addConn, 1, 3
				
				 if not pRS.EOF then
				 Do While Not pRS.EOF
					%>
					
					<div class="post">
						<h2 class="titleblog"><a href="default.asp?modulo=blog&amp;pass=1&amp;idpost=<%=pRS("id_post")%>" title="<%=pRS("titolo")%>"><%=pRS("titolo")%></a></h2>
		
						<small class="datablog"><%=strToDate(pRS("data"))%></small><br /><br />
		
						<div class="entry">
						<%
						
						if RIASTEXT = 0 then 'riassunto
							if pRS("riassunto") <> "" then
								response.Write pRS("riassunto")
							else
								rias = pRS("contenuto")
								call removeHtmlChar(rias)
								response.Write TextPreview(rias, 500) 
							end if
						else
							response.Write pRS("contenuto")
						end if
						
						%>
						</div>
						<%totale = totCommenti(pRS("id_post"))%>
						<p class="postmetadata">
						<img src="themes/MODULI_IMG/MODULO_BLOG/speech_bubble.gif" alt="" /> <a href="default.asp?modulo=blog&amp;pass=1&amp;idpost=<%=pRS("id_post")%>" title="<%= traduci("ling_blog_21") & pRS("titolo")%>"><%=totale%> 
						<% 
						if totale = "1" then 
							response.Write traduci("ling_blog_23") 
						else
							response.Write traduci("ling_blog_24") 
						end if
						%></a>				| <img src="themes/MODULI_IMG/MODULO_BLOG/documents.gif" alt="" /> <a href="default.asp?modulo=blog&amp;pass=2&amp;cat=<%=pRS("categoria")%>" title="<%= traduci("ling_blog_22") & nomeCat(pRS("categoria"))%>" rel="category tag"><%=nomeCat(pRS("categoria"))%></a> | <img src="themes/MODULI_IMG/MODULO_BLOG/figure_ver1.gif" alt="" /> Pubblicato da <%=username(pRS("utente"))%>				 
						</p>
					</div>                            
            <%
			pRS.MoveNext
			loop
			else
				With response
					.Write "<p style=""text-align:center"">"&vbNewLine
					.Write traduci("ling_blog_82")
					.Write "</p>"&vbNewLine
				End with
			End if
else
					Set pRS = Server.CreateObject("ADODB.RecordSet")
						
						strSQL =  "SELECT * FROM tb_blog_posts WHERE blog = " & idblog & " AND pubblico = 1 ORDER BY id_post DESC"
						pRS.Open strSQL, addConn, 1, 3
						
						'configuro il recordset per la paginazione
						pRS.PageSize = iPageSize
						pRS.CacheSize = iPageSize
						'recupero il totale dei record
						reccount = pRS.recordcount
						'Recupero il totale delle pagine
						iPageCount = pRS.PageCount
						'Se la pagina corrente è maggiore del totale delle pagine vado all'ultima
						if iPageCurrent > iPageCount Then iPageCurrent = iPageCount
							'Se la pagina corrente è minore di 1 vado alla pagina 1
							if iPageCurrent < 1 Then iPageCurrent = 1   
							If iPageCount = 0 Then
									With response
										.Write "<p style=""text-align:center"">"&vbNewLine
										.Write traduci("ling_blog_82")
										.Write "</p>"&vbNewLine
									End with
							Else
								pRS.AbsolutePage = iPageCurrent
								iRecordsShown = 0
								cont=1
								Do While iRecordsShown < iPageSize And Not pRS.EOF
									%>
									
									<div class="post" id="post-<%=p%>">
										<h2 class="titleblog"><a href="default.asp?modulo=blog&amp;pass=1&amp;idpost=<%=pRS("id_post")%>" title="<%=pRS("titolo")%>"><%=pRS("titolo")%></a></h2>
						
										<small class="datablog"><%=strToDate(pRS("data"))%></small><br /><br />
						
										<div class="entry">
										<%
										
										if RIASTEXT = 0 then 'riassunto
											if pRS("riassunto") <> "" then
												response.Write pRS("riassunto")
											else
												rias = pRS("contenuto")
												call removeHtmlChar(rias)
												response.Write TextPreview(rias, 500) 
											end if
										else
											response.Write pRS("contenuto")
										end if
										
										%>
										</div>
										<%totale = totCommenti(pRS("id_post"))%>
										<p class="postmetadata">
										<img src="themes/MODULI_IMG/MODULO_BLOG/speech_bubble.gif" alt="" /> <a href="default.asp?modulo=blog&amp;pass=1&amp;idpost=<%=pRS("id_post")%>" title="<%= traduci("ling_blog_21") & pRS("titolo")%>"><%=totale%> 
										<% 
										if totale = "1" then 
											response.Write traduci("ling_blog_23") 
										else
											response.Write traduci("ling_blog_24") 
										end if
										%></a>				| <img src="themes/MODULI_IMG/MODULO_BLOG/documents.gif" alt="" /> <a href="default.asp?modulo=blog&amp;pass=2&amp;cat=<%=pRS("categoria")%>" title="<%= traduci("ling_blog_22") & nomeCat(pRS("categoria"))%>" rel="category tag"><%=nomeCat(pRS("categoria"))%></a> | <img src="themes/MODULI_IMG/MODULO_BLOG/figure_ver1.gif" alt="" /> Pubblicato da <%=username(pRS("utente"))%>				 
										</p>
									</div>                            
									<%									
									Cont = Cont + 1
									'POSIZIONAMENTO ALLA RIGA SUCCESSIVA DEL DB
									iRecordsShown = iRecordsShown + 1
									pRS.MoveNext
								loop	
						End if												
				End if				
				%>                
           		<div style="text-align:center">
                <%if iPageCount > 1 then%>
                <%if iPageCurrent > 1 and iPageCurrent < iPageCount then%> 
                	   <a class="testo" href="default.asp?modulo=blog&amp;page=<%=iPageCurrent+1%>"><%=traduci("ling_blog_53")%></a>&nbsp;
                       <a class="testo" href="default.asp?modulo=blog&amp;page=<%=iPageCurrent-1%>"><%=traduci("ling_blog_54")%></a>&nbsp;
                <%elseif iPageCurrent >= iPageCount then%>
                    &nbsp;<a class="testo" href="default.asp?modulo=blog&amp;page=<%=iPageCurrent-1%>"><%=traduci("ling_blog_54")%></a>&nbsp;
                <%elseif iPageCurrent < iPageCount then%>
                    &nbsp;<a class="testo" href="default.asp?modulo=blog&amp;page=<%=iPageCurrent+1%>"><%=traduci("ling_blog_53")%></a>&nbsp;
                <%end if%>
				<%end if%>	
                </div>
<%							
Set pRS = Nothing
CASE 1: 'Lettura di un post con commenti
strSQL = "SELECT * FROM tb_blog_posts WHERE id_post = " & testSQLinj(request.QueryString("idpost"))

Set pRS = addConn.Execute(strSQL)
if NOT pRS.EOF then

if pRS("pubblico") = 0 then
	if session("livelloUser") = 2 or isAdm(session("uID"), "blog") or isBlogMod(session("uID"),pRS("categoria")) then
		autv = true
	else
		autv = false
	end if
else
	autv = true
end if

if autv then
addConn.Execute("UPDATE tb_blog_posts SET view = view + 1 WHERE id_post = " & testSQLinj(request.QueryString("idpost")) & " AND pubblico = 1")

%>
			<div class="post" id="post-<%=p%>">
				<h2 class="titleblog"><a href="default.asp?modulo=blog&amp;pass=1&amp;idpost=<%=pRS("id_post")%>" title="<%=pRS("titolo")%>"><%=pRS("titolo")%></a></h2>

				<small class="datablog"><%=strToDate(pRS("data"))%></small><br /><br />

				<div class="entry">
                <%=pRS("contenuto")%>
                </div>
				
                 <br />              
				<%
				iPageSize = MAX_COM_PAGE
			'se non si stà richiedendo nessuna pagina assegno per default il valore 1
				If Request.QueryString("page") = "" Then
					iPageCurrent = 1
				Else
					'Altrimenti assegno la pagina recuperata
					iPageCurrent = CInt(Request.QueryString("page"))
				End If	
									
				if DB_TYPE = "mysql" then
					
				start = (iPageCurrent -1)*iPageSize
				send = iPageSize

				SQL = "SELECT Count(*) AS TOTALE FROM tb_blog_commenti WHERE post = " & testSQLinj(request.QueryString("idpost")) & " AND pubblico = 1 ORDER BY id_commento DESC"
			
				Set a = objConn.Execute(SQL)	
				tot = Cint(a("TOTALE"))
				'Recupero il totale delle pagine
				if tot < iPageSize then
					iPageCount = 1
				elseif tot mod iPageSize = 0 then
					iPageCount = Int(tot/iPageSize)
				else
					iPageCount = Int((tot/iPageSize)) + 1
				End if				
	
				Set objRS = Server.CreateObject("ADODB.RecordSet")
				strSQL = "SELECT * FROM tb_blog_commenti WHERE post = " & testSQLinj(request.QueryString("idpost")) & " AND pubblico = 1 ORDER BY id_commento Limit "&start&","&send&""
				objRS.Open strSQL, addConn, 1, 3
				
				 if not objRS.EOF then
				 %>

                <b>Commenti a: <%=pRS("titolo")%></b>
                <br />
                <%
				 Do While Not objRS.EOF
					response.Write "<div class=""comment""><div class=""cbody"">"
					 response.Write "<small><a href=""#comment-"&Cont&""" title="""">"&strToDate(objRS("data"))&"</a> </small><br /><br />"  & replace(objRS("testo"), "[br]", "<br />")
					 response.Write "</div><div class=""author"">"
					 if trim(objRS("sitoweb")) <> "" and trim(objRS("sitoweb")) <> "http://" then
						 response.Write "<a href=""http://"&replace(objRS("sitoweb"), "http://", "")&""" target = ""_blank"">" & objRS("nome") & "</a>"
					 else
						 response.Write objRS("nome")
					 end if
					 response.Write "</div></div>"

					objRS.MoveNext
				loop
				End if
				
				Else 'Access
						Set objRS = Server.CreateObject("ADODB.RecordSet")
						
						strSQL = "SELECT * FROM tb_blog_commenti WHERE post = " & testSQLinj(request.QueryString("idpost")) & " AND pubblico = 1 ORDER BY id_commento"
						objRS.Open strSQL, addConn, 1, 3
						
						'configuro il recordset per la paginazione
						objRS.PageSize = iPageSize
						objRS.CacheSize = iPageSize
						'recupero il totale dei record
						reccount = objRS.recordcount
						'Recupero il totale delle pagine
						iPageCount = objRS.PageCount
						'Se la pagina corrente è maggiore del totale delle pagine vado all'ultima
						if iPageCurrent > iPageCount Then iPageCurrent = iPageCount
							'Se la pagina corrente è minore di 1 vado alla pagina 1
							if iPageCurrent < 1 Then iPageCurrent = 1   
							If iPageCount = 0 Then
									With response
										Write "<P>"&vbNewLine
		
										.Write "</P>"&vbNewLine
									End with
							Else
								objRS.AbsolutePage = iPageCurrent
								iRecordsShown = 0
								cont=1
								Do While iRecordsShown < iPageSize And Not objRS.EOF
									response.Write "<div class=""comment""><div class=""cbody"">"
									 response.Write "<small><a href=""#comment-"&Cont&""" title="""">"&strToDate(objRS("data"))&"</a> </small><br /><br />"  & replace(objRS("testo"), "[br]", "<br />")
									 response.Write "</div><div class=""author"">"
									 if trim(objRS("sitoweb")) <> "" and trim(objRS("sitoweb")) <> "http://" then
									 	 response.Write "<a href="""&replace(objRS("sitoweb"), "http://", "")&""" target = ""_blank"">" & objRS("nome") & "</a>"
									 else
										 response.Write objRS("nome")
									 end if
									 response.Write "</div></div>"
									Cont = Cont + 1
									'POSIZIONAMENTO ALLA RIGA SUCCESSIVA DEL DB
									iRecordsShown = iRecordsShown + 1
									objRS.MoveNext
								loop	
						End if												
				End if				
				%>                
           		<div style="text-align:center">
                <%if iPageCount > 1 then%>
                <%if iPageCurrent > 1 and iPageCurrent < iPageCount then%>
                       <a class="testo" href="default.asp?modulo=blog&amp;pass=1&amp;idpost=<%=request.QueryString("idpost")%>&amp;page=<%=iPageCurrent-1%>"><%=traduci("ling_blog_55")%></a>&nbsp;
                   
                       <a class="testo" href="default.asp?modulo=blog&amp;pass=1&amp;idpost=<%=request.QueryString("idpost")%>&amp;page=<%=iPageCurrent+1%>"><%=traduci("ling_blog_56")%></a>&nbsp;
                <%elseif iPageCurrent >= iPageCount then%>
                    &nbsp;<a class="testo" href="default.asp?modulo=blog&amp;pass=1&amp;idpost=<%=request.QueryString("idpost")%>&amp;page=<%=iPageCurrent-1%>"><%=traduci("ling_blog_55")%></a>&nbsp;
                <%elseif iPageCurrent < iPageCount then%>
                    &nbsp;<a class="testo" href="default.asp?modulo=blog&amp;pass=1&amp;idpost=<%=request.QueryString("idpost")%>&amp;page=<%=iPageCurrent+1%>"><%=traduci("ling_blog_56")%></a>&nbsp;
                <%end if%>
				<%end if%>
           		</div>       
                
                <br />
	            <div id="feed"><a class="testo" title="rss- <%=traduci("ling_blog_75")%>" href="default.asp?modulo=blog&amp;file=rss&amp;type=comm&amp;id=<%=request.QueryString("idpost")%>"><img src="themes/MODULI_IMG/MODULO_BLOG/feed.gif" style="border:0" alt="rss- <%=traduci("ling_blog_74")%>" /> <%=traduci("ling_blog_75")%> </a></div>
                <br />
                
                <%
				if REG_COM = 0 then
				%>         
                <h3 id="respond"><%=traduci("ling_blog_1")%></h3>
             
             	<p class="errore">
                	<%
					if request.QueryString("errore") = "1" then
						response.Write traduci("ling_blog_25")
					end if
					%>
                </p>
             
                <form action="default.asp?modulo=blog&amp;file=sendcomment" method="post" id="commentform">
                
                
                <p><input type="text" name="author" id="author" value="" size="22" tabindex="1" />
                <label for="author"><small><%=traduci("ling_blog_2")%></small></label></p>
                
                <p><input type="text" name="email" id="email" value="" size="22" tabindex="2" />
                <label for="email"><small><%=traduci("ling_blog_3")%></small></label></p>
                
                <p><input type="text" name="url" id="url" value="" size="22" tabindex="3" />
                <label for="url"><small><%=traduci("ling_blog_4")%></small></label></p>
                
            
                <p><textarea name="comment" id="comment" cols="50" rows="10" tabindex="4"></textarea></p>
                
                <p><input name="submit" type="submit" id="submit" tabindex="5" value="<%=traduci("ling_blog_5")%>" />
                <input type="hidden" name="postID" value="<%=request.QueryString("idpost")%>" />
                <input type="hidden" name="commID" value="<%=cont%>" />
                </p>
                </form>
                <%
				else
					if session("uID") <> "" and session("uID") <> 0 then
				%>
                    <h3 id="respond"><%=traduci("ling_blog_1")%></h3>
                 
                    <p class="errore">
                        <%
                        if request.QueryString("errore") = "1" then
                            response.Write traduci("ling_blog_25")
                        end if
                        %>
                    </p>
                 
                    <form action="default.asp?modulo=blog&amp;file=sendcomment" method="post" id="commentform">
                    
                    <p><textarea name="comment" id="comment" cols="50" rows="10" tabindex="4"></textarea></p>
                    
                    <p><input name="submit" type="submit" id="submit" tabindex="5" value="<%=traduci("ling_blog_5")%>" />
                    <input type="hidden" name="postID" value="<%=request.QueryString("idpost")%>" />
                    <input type="hidden" name="commID" value="<%=cont%>" />
                    <input type="hidden" name="reg" value="true" />
                    </p>                	
                    </form>
                <%
					else
						response.Write "<div style=""text-align:center"">" & traduci("ling_blog_57") & "</div>"
					end if
				end if
				%>
            </div>                              
<%
end if
else
	Response.Write "<p style=""text-align:center"">"					 	

	Response.Write "</p>" 
end if
Set pRS = Nothing
CASE 2:
iPageSize = MAX_POST_PAGE
if DB_TYPE = "mysql" then
				'se non si stà richiedendo nessuna pagina assegno per default il valore 1
				If Request.QueryString("page") = "" Then
					iPageCurrent = 1
				Else
					'Altrimenti assegno la pagina recuperata
					iPageCurrent = CInt(Request.QueryString("page"))
				End If	
					
					
				start = (iPageCurrent -1)*iPageSize
				send = iPageSize

				SQL = "SELECT count(*) AS TOTALE FROM tb_blog_posts WHERE blog = " & idblog & " AND pubblico = 1 AND categoria = "&testSQLinj(request.QueryString("cat"))&" ORDER BY id_post DESC"
			
				Set a = objConn.Execute(SQL)	
				tot = Cint(a("TOTALE"))
				'Recupero il totale delle pagine
				if tot < iPageSize then
					iPageCount = 1
				elseif tot mod iPageSize = 0 then
					iPageCount = Int(tot/iPageSize)
				else
					iPageCount = Int((tot/iPageSize)) + 1
				End if				
	
				Set pRS = Server.CreateObject("ADODB.RecordSet")
				strSQL = "SELECT * FROM tb_blog_posts WHERE blog = " & idblog & " AND pubblico = 1 AND categoria = "&testSQLinj(request.QueryString("cat"))&" ORDER BY id_post DESC Limit "&start&","&send&""
				pRS.Open strSQL, addConn, 1, 3
				
				 if not pRS.EOF then
				 Do While Not pRS.EOF
					%>
					
					<div class="post" id="post-<%=p%>">
						<h2 class="titleblog"><a href="default.asp?modulo=blog&amp;pass=1&amp;idpost=<%=pRS("id_post")%>" title="<%=pRS("titolo")%>"><%=pRS("titolo")%></a></h2>
		
						<small class="datablog"><%=strToDate(pRS("data"))%></small><br /><br />
		
						<div class="entry">
						<%
						
						if RIASTEXT = 0 then 'riassunto
							if pRS("riassunto") <> "" then
								response.Write pRS("riassunto")
							else
								rias = pRS("contenuto")
								call removeHtmlChar(rias)
								response.Write TextPreview(rias, 500) 
							end if
						else
							response.Write pRS("contenuto")
						end if
						
						%>
						</div>
						<%totale = totCommenti(pRS("id_post"))%>
						<p class="postmetadata">
						<img src="themes/MODULI_IMG/MODULO_BLOG/speech_bubble.gif" alt="" /> <a href="default.asp?modulo=blog&amp;pass=1&amp;idpost=<%=pRS("id_post")%>" title="<%= traduci("ling_blog_21") & pRS("titolo")%>"><%=totale%> 
						<% 
						if totale = "1" then 
							response.Write traduci("ling_blog_23") 
						else
							response.Write traduci("ling_blog_24") 
						end if
						%></a>				| <img src="themes/MODULI_IMG/MODULO_BLOG/documents.gif" alt="" /> <a href="default.asp?modulo=blog&amp;pass=2&amp;cat=<%=pRS("categoria")%>" title="<%= traduci("ling_blog_22") & nomeCat(pRS("categoria"))%>" rel="category tag"><%=nomeCat(pRS("categoria"))%></a> | <img src="themes/MODULI_IMG/MODULO_BLOG/figure_ver1.gif" alt="" /> Pubblicato da <%=username(pRS("utente"))%>				 
						</p>
					</div>                            
            <%
			pRS.MoveNext
			loop
			End if
else
					Set objRS = Server.CreateObject("ADODB.RecordSet")
						
						strSQL =  "SELECT * FROM tb_blog_posts WHERE blog = " & idblog & " AND pubblico = 1 AND categoria = "&testSQLinj(request.QueryString("cat"))&" ORDER BY id_post DESC"
						objRS.Open strSQL, addConn, 1, 3
						
						'configuro il recordset per la paginazione
						objRS.PageSize = iPageSize
						objRS.CacheSize = iPageSize
						'recupero il totale dei record
						reccount = objRS.recordcount
						'Recupero il totale delle pagine
						iPageCount = objRS.PageCount
						'Se la pagina corrente è maggiore del totale delle pagine vado all'ultima
						if iPageCurrent > iPageCount Then iPageCurrent = iPageCount
							'Se la pagina corrente è minore di 1 vado alla pagina 1
							if iPageCurrent < 1 Then iPageCurrent = 1   
							If iPageCount = 0 Then
									With response
										Write "<P>"&vbNewLine
		
										.Write "</P>"&vbNewLine
									End with
							Else
								objRS.AbsolutePage = iPageCurrent
								iRecordsShown = 0
								cont=1
								Do While iRecordsShown < iPageSize And Not objRS.EOF
									%>
									
									<div class="post" id="post-<%=p%>">
										<h2 class="titleblog"><a href="default.asp?modulo=blog&amp;pass=1&amp;idpost=<%=pRS("id_post")%>" title="<%=pRS("titolo")%>"><%=pRS("titolo")%></a></h2>
						
										<small class="datablog"><%=strToDate(pRS("data"))%></small><br /><br />
						
										<div class="entry">
										<%
										
										if RIASTEXT = 0 then 'riassunto
											if pRS("riassunto") <> "" then
												response.Write pRS("riassunto")
											else
												rias = pRS("contenuto")
												call removeHtmlChar(rias)
												response.Write TextPreview(rias, 500) 
											end if
										else
											response.Write pRS("contenuto")
										end if
										
										%>
										</div>
										<%totale = totCommenti(pRS("id_post"))%>
										<p class="postmetadata">
										<img src="themes/MODULI_IMG/MODULO_BLOG/speech_bubble.gif" alt="" /> <a href="default.asp?modulo=blog&amp;pass=1&amp;idpost=<%=pRS("id_post")%>" title="<%= traduci("ling_blog_21") & pRS("titolo")%>"><%=totale%> 
										<% 
										if totale = "1" then 
											response.Write traduci("ling_blog_23") 
										else
											response.Write traduci("ling_blog_24") 
										end if
										%></a>				| <img src="themes/MODULI_IMG/MODULO_BLOG/documents.gif" alt="" /> <a href="default.asp?modulo=blog&amp;pass=2&amp;cat=<%=pRS("categoria")%>" title="<%= traduci("ling_blog_22") & nomeCat(pRS("categoria"))%>" rel="category tag"><%=nomeCat(pRS("categoria"))%></a> | <img src="themes/MODULI_IMG/MODULO_BLOG/figure_ver1.gif" alt="" /> Pubblicato da <%=username(pRS("utente"))%>				 
										</p>
									</div>                            
									<%									
									Cont = Cont + 1
									'POSIZIONAMENTO ALLA RIGA SUCCESSIVA DEL DB
									iRecordsShown = iRecordsShown + 1
									objRS.MoveNext
								loop	
						End if												
				End if				
				%>                
           		<div style="text-align:center">
                <%if iPageCount > 1 then%>
                <%if iPageCurrent > 1 and iPageCurrent < iPageCount then%> 
                	   <a class="testo" href="default.asp?modulo=blog&amp;pass=2&amp;cat=<%=request.QueryString("cat")%>&amp;page=<%=iPageCurrent+1%>"><%=traduci("ling_blog_53")%></a>&nbsp;
                       <a class="testo" href="default.asp?modulo=blog&amp;pass=2&amp;cat=<%=request.QueryString("cat")%>&amp;page=<%=iPageCurrent-1%>"><%=traduci("ling_blog_54")%></a>&nbsp;
                <%elseif iPageCurrent >= iPageCount then%>
                    &nbsp;<a class="testo" href="default.asp?modulo=blog&amp;pass=2&amp;cat=<%=request.QueryString("cat")%>&amp;page=<%=iPageCurrent-1%>"><%=traduci("ling_blog_54")%></a>&nbsp;
                <%elseif iPageCurrent < iPageCount then%>
                    &nbsp;<a class="testo" href="default.asp?modulo=blog&amp;pass=2&amp;cat=<%=request.QueryString("cat")%>&amp;page=<%=iPageCurrent+1%>"><%=traduci("ling_blog_53")%></a>&nbsp;
                <%end if%>
				<%end if%>	
                </div>
<%							
Set pRS = Nothing
End select
%>
